package com.cqie.tes.controller;


import com.cqie.tes.comm.R;
import com.cqie.tes.domain.SysFunc;
import com.cqie.tes.domain.SysRole;
import com.cqie.tes.domain.qo.SysFuncQo;
import com.cqie.tes.domain.qo.SysRoleQo;
import com.cqie.tes.service.SysFuncService;
import com.cqie.tes.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("角色管理")
@CrossOrigin
//@Slf4j
@RestController
@RequestMapping("/sysfunc")
public class SysFuncController {

    @Autowired
    SysFuncService sysFuncService;

    @ApiOperation("分页查询列表")
    @PostMapping("/list")
    public R list(SysFuncQo qo){
        return sysFuncService.getList(qo);
    }

    @ApiOperation("新增角色")
    @PostMapping("/add")
    public R add(
            @ApiParam(name = "entity",value = "角色对象") SysFunc entity){
        return sysFuncService.edit(entity);
    }

    @ApiOperation("修改角色")
    @PostMapping("/update")
    public R update(SysFunc entity) {
        System.out.println(entity.toString());
        return sysFuncService.edit(entity);
    }

    @ApiOperation("根据ID删除")
    @GetMapping("/delete/{id}")
    public R delete(
            @ApiParam(value = "角色ID") @PathVariable("id") Integer id
    ){
        return sysFuncService.deleteById(id);
    }

    @ApiOperation("根据ID批量删除")
    @GetMapping("/batchDelete/{ids}")
    public R batchDelete(
            @ApiParam(value = "角色ID列表:1,2,3") @PathVariable("ids") String ids
    ){
        return sysFuncService.deleteByIds(ids);
    }
}
